import requestApi from "src/erm/sscrppublic/common/components/requestApi";
import { toast } from 'nc-lightapp-front';
import {ajax } from 'nc-lightapp-front';


let requestDomain =  '';

let requestApiOverwrite = {
    ...requestApi,
    /**
     * //  pk_psndoc
     * @param {} prams 
     */
    bagQuery:(prams) => {
         ajax({
            url: `${requestDomain}/nccloud/erm/ybzinvoice/NcInvoiceBagListQueryAction.do`,
            data: prams.data,
            success: (data) => {
                if(data && data.success && Array.isArray(data.data)){
                    prams.success(data.data);
                }
            },
            error: (err) => {
                // console.log(prams);
                // if(err && err.message){
                //     toast({ color: 'warning', content: err.message}); /*扫描条码未查询到单据*/
                // }
                prams.error();
            }
        })
    },
    //  pk_psndoc
    bagInsert: (prams) => {
        ajax({
            url: `${requestDomain}/nccloud/erm/ybzinvoice/NcInvoiceBagInsertAction.do`,
            data: prams.data,
            success: (data) => {
                if(data && data.success && Array.isArray(data.data)){
                    prams.success(data.data);
                }
            },
            error: (err) => {
                prams.error();
                if(err && err.message){
                    toast({ color: 'warning', content: err.message}); /*扫描条码未查询到单据*/
                }
            }
        })
    },
    //  pk_psndoc
    bagUpdate: (prams) => {
        ajax({
            url: `${requestDomain}/nccloud/erm/ybzinvoice/NcInvoiceBagUpdateBagNameAction.do`,
            data: prams.data,
            success: (data) => {
                if(data && data.success && Array.isArray(data.data)){
                    prams.success(data.data);
                }
            },
            error: (err) => {
                prams.error();
                if(err && err.message){
                    toast({ color: 'warning', content: err.message}); /*扫描条码未查询到单据*/
                }
            }
        })
    },

    bagDelete: (prams) => {
        ajax({
            url: `${requestDomain}/nccloud/erm/ybzinvoice/NcInvoiceBagDeleteAction.do`,
            data: prams.data,
            success: (data) => {
                if(data && data.success && Array.isArray(data.data)){
                    prams.success(data.data);
                }
            },
            error: (err) => {
                prams.error();
                if(err && err.message){
                    toast({ color: 'warning', content: err.message}); /*扫描条码未查询到单据*/
                }
            }
        })
    }
}

export default  requestApiOverwrite;